/**************************************************************************
* This file is part of Hawkengine.
*
* Hawkengine is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Hawkengine is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Hawkengine.  If not, see <http://www.gnu.org/licenses/>.
**************************************************************************/


/**************************************************************************
* Dependencies
**************************************************************************/
#include "engine/color.h"

/**************************************************************************
* Preprocessing
**************************************************************************/

/**************************************************************************
* Types
**************************************************************************/

/**************************************************************************
* Variables
**************************************************************************/
const color_type BLACK = {0, 0, 0, 255};
const color_type WHITE = {255, 255, 255, 255};
const color_type RED = {255, 0, 0, 255};
const color_type GREEN = {0, 255, 0, 255};
const color_type BLUE = {0, 0, 255, 255};
const color_type YELLOW = {255, 255, 0, 255};
const color_type MAGENTA = {255, 0, 255, 255};
const color_type CYAN = {0, 255, 255, 255};

const color_type GOLD = {217, 217, 25, 255};
const color_type SILVER = {230, 232, 250, 255};
const color_type BRONZE = {166, 125, 61, 255};

const color_type OVERLAY_COLOR = {64, 64, 64, 222};
const color_type ACTIVE_TEXT_COLORS[] = {
  {128, 128, 128, 255}, {255, 255, 255, 255},
};
const color_type DEBUG_BG_COLOR = {0, 0, 0, 96};
const color_type DEBUG_FG_COLOR = {255, 255, 255, 128};

/**************************************************************************
* Static Variables
**************************************************************************/

/**************************************************************************
* Function Prototypes
**************************************************************************/

/**************************************************************************
* Function Implementations
**************************************************************************/
void color_blend(const color_type* color1, const color_type* color2,
                 float divider, color_type* color)
{
  _UPDATE_MAX(divider, 0);
  _UPDATE_MIN(divider, 1);
  color->r = (UCHAR)((int)(((1 - divider) * color1->r) + (divider * color2->r)));
  color->g = (UCHAR)((int)(((1 - divider) * color1->g) + (divider * color2->g)));
  color->b = (UCHAR)((int)(((1 - divider) * color1->b) + (divider * color2->b)));
  color->a = (UCHAR)((int)(((1 - divider) * color1->a) + (divider * color2->a)));
}

BOOL color_matching(const color_type* color1, const color_type* color2)
{
  return ((color1->r == color2->r) &&
          (color1->g == color2->g) &&
          (color1->b == color2->b) &&
          (color1->a == color2->a));
}

